
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Loading Tab Content</title>

<style type="text/css">
/*margin and padding on body element
  can introduce errors in determining
  element position and are not recommended;
  we turn them off as a foundation for YUI
  CSS treatments. */
body {
	margin:0;
	padding:0;
}
</style>

<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
<script type="text/javascript" src="../../build/yui/yui-min.js"></script>


<!--begin custom header content for this example-->
<style id="yui3-style-overrides">
#demo {
    width: 50em;
}

.yui3-tab-loading {
    background: #fff url(http://developer.yahoo.com/yui/3/examples/overlay/assets/img/ajax-loader.gif) no-repeat center center;
    height:40px;
}

#main #example-canvas .yui3-tabview .yui3-tab-selected a {
	color:white;
}
</style>
<!--end custom header content for this example-->

</head>

<body class="yui3-skin-sam  yui-skin-sam">

<h1>Loading Tab Content</h1>

<div class="exampleIntro">
	This example shows how to plug <code>IO</code> functionality into <code>TabView</code> so
that data can be loaded remotely.
			
</div>

<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

<div id="demo"></div>
<script type="text/javascript">
YUI({ filter: 'raw' }).use("yui", "tabview", "gallery-widget-io", function(Y) {
    var feeds = {
        Chrome: 'assets/news.php?query=chrome+browser',
        Firefox: 'assets/news.php?query=firefox+browser',
        Safari: 'assets/news.php?query=safari+browser',
        Explorer: 'assets/news.php?query=explorer+browser'
    },

    TabIO = function(config) {
        TabIO.superclass.constructor.apply(this, arguments); 
    };

    Y.extend(TabIO, Y.Plugin.WidgetIO, {
        initializer: function() {
            var tab = this.get('host');
            tab.on('selectedChange', this.afterSelectedChange);
        },

        afterSelectedChange: function(e) { // this === tab
            if (e.newVal) { // tab has been selected
                this.io.refresh();
            }
        },

        setContent: function(content) {
            var tab = this.get('host');
            tab.set('content', content);
        },

        _toggleLoadingClass: function(add) {
            this.get('host').get('panelNode')
                .toggleClass(this.get('host').getClassName('loading'), add);
        }

    }, {
        NAME: 'tabIO',
        NS: 'io'
    });

    var tabview = new Y.TabView();

    Y.each(feeds, function(src, label) {
        tabview.add({
            label: label,
            plugins: [{
                fn: TabIO, 
                cfg: {
                    uri: src
                }
            }]
        });
    });

    tabview.render('#demo');
});
</script>

<!--END SOURCE CODE FOR EXAMPLE =============================== -->

</body>
</html>
